<!DOCTYPE html>
<html lang="zh-CN" ng-app="ngApp" class="ng-scope">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Template</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <!-- date picker -->
    <link href="https://cdn.bootcss.com/bootstrap-datetimepicker/2.1.30/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet">

    <link rel="stylesheet" href="static/css/bootstrap-datetimepicker.min.css">
</head>
<body ng-controller="mainCtrl">
<div class="container">
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                        aria-expanded="false" aria-controls="navbar" style="padding: 0px 0px;">
                    <img id="user_header_img" width="32" height="32"/>
                </button>
                <a class="navbar-brand" href="#" len="12" lang="zh" ng-bind="title"></a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
            </div><!--/.nav-collapse -->
        </div>
    </nav>
    <div ui-view>
    </div>
    <nav class="navbar navbar-default navbar-fixed-bottom">
        <div class="col-xs-4 btn-group dropup" style="height:50px;padding:0">
            <button type="button" class="btn btn-lg btn-default dropdown-toggle" style="padding:0;vertical-align:middle;width:100%;height:100%;border-radius: 0;border-width:0 0 0 1px" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                更多<span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <li><a ui-sref="queryException">异常信息查询</a></li>
                <li role="separator" class="divider"></li>
                <li><a ui-sref="queryCCTVImages">CCTV图片查询</a></li>
                <li role="separator" class="divider"></li>
                <li><a ui-sref="register">用户注册</a></li>
            </ul>
        </div>
        <div class="col-xs-4" style="height:50px;padding:0"><button class="btn btn-lg btn-default" style="padding:0;vertical-align:middle;width:100%;height:100%;border-radius: 0;border-width:0 0 0 1px"><a ui-sref="subscription" style="text-decoration: none;color: black">订阅设置</a></button></div>
        <div class="col-xs-4" style="height:50px;padding:0"><button class="btn btn-lg btn-default" style="padding:0;vertical-align:middle;width:100%;height:100%;border-radius: 0;border-width:0 0 0 1px"><a ui-sref="queryCheckinRecord" style="text-decoration: none;color: black">考勤记录查询</a></button></div>
    </nav>
</div>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

<!-- angularjs -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.2/angular.js"></script>
<script src="//unpkg.com/@uirouter/angularjs/release/angular-ui-router.min.js"></script>
<!-- datetime picker-->
<script src="static/js/bootstrap-datetimepicker.js"></script>
<script src="static/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script>
    var getQueryString = function (name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    };
    code = getQueryString("code");
    console.log(code);
	var getAccessToken = function(){
    $.ajax({
        type:"GET",
        url:"http://test.wechat.inuorui.com/api/user/accessToken?appId=wx751d208200afe9d0&code="+code,
        success:function (res) {
            console.log(res.reCode);
			getUserInfo(res.reData.access_token,res.reData.openid);
        }
    });
	}
	var getUserInfo = function(access_token,openid){
	console.log(access_token);
	$.ajax({
        type:"GET",
        url:"http://test.wechat.inuorui.com/api/user/info?accessToken="+access_token+"&openid="+openid,
        success:function (res) {
			console.log(res.reCode);
			console.log(res.reData.nickname);
			$("#user_header_img").attr('src',res.reData.headimgurl);
        }
    });
	}
	getAccessToken();
</script>
<!-- js -->
<script src="static/js/app.js"></script>

</body>
</html>